package com.xie.smfs.event;

import com.xie.smfs.entity.VillagerGhostEntity;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;

public class EntityAttackListener {
    public static void register() {
        AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            if (!world.isClient && player instanceof ServerPlayerEntity && entity instanceof VillagerEntity) {
                // 当玩家攻击村民时记录攻击行为
                VillagerGhostEntity.recordVillagerAttack(player);
            }
            return ActionResult.PASS;
        });
    }
}